﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			 xmlns:viewModel="clr-namespace:SqlServerRunnerNet.Controls.DirectoryTreeView.ViewModel"
			 xmlns:common="clr-namespace:SqlServerRunnerNet.Controls.Common"
			 x:Class="SqlServerRunnerNet.Controls.DirectoryTreeView.DirectoryTreeViewControl"
			 mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">
	<TreeView x:Name="FoldersTreeView" ItemsSource="{Binding (viewModel:DirectoryModelCollection.Roots)}">
		<TreeView.Resources>
			<HierarchicalDataTemplate ItemsSource="{Binding Children}" DataType="{x:Type viewModel:DriveViewModel}">
				<StackPanel Orientation="Horizontal">
					<CheckBox VerticalAlignment="Center" IsChecked="{Binding IsChecked}" Focusable="False"/>
					<Image x:Name="nodeImg" Source="/SqlServerRunnerNet;component/Images/drive.png" Margin="5,0,2,0" Focusable="False" />
					<TextBlock Text="{Binding DisplayPath}" Focusable="False" />
				</StackPanel>
			</HierarchicalDataTemplate>
			<HierarchicalDataTemplate ItemsSource="{Binding Children}" DataType="{x:Type viewModel:FolderViewModel}">
				<StackPanel Orientation="Horizontal">
					<CheckBox VerticalAlignment="Center" IsChecked="{Binding IsChecked}" Focusable="False"/>
					<Image x:Name="nodeImg" Source="/SqlServerRunnerNet;component/Images/folder-closed.png" Margin="5,0,2,0" Focusable="False" />
					<TextBlock Text="{Binding DisplayPath}" VerticalAlignment="Center" Focusable="False" />
				</StackPanel>
				<HierarchicalDataTemplate.Triggers>
					<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=TreeViewItem}, Path=IsExpanded}" Value="True">
						<Setter TargetName="nodeImg" Property="Source" Value="/SqlServerRunnerNet;component/Images/folder-open.png" />
					</DataTrigger>
				</HierarchicalDataTemplate.Triggers>
			</HierarchicalDataTemplate>
			<Style TargetType="{x:Type TreeViewItem}">
				<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
				<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
				<Setter Property="KeyboardNavigation.AcceptsReturn" Value="True" />
				<Setter Property="common:VirtualToggleButton.IsVirtualToggleButton" Value="True" />
				<Setter Property="common:VirtualToggleButton.IsChecked" Value="{Binding IsChecked}" />
			</Style>
		</TreeView.Resources>
	</TreeView>
</UserControl>
